/**
 * Date:2018年1月9日上午11:15:46
 *
 */

package com.app.common.core;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 
 * Description: 应用程序响应类 <br/>
 * Date:2019年9月29日 下午2:38:41 <br/>
 * 
 * @author xuejianxin
 */
class AppResponse implements Serializable {

	private static final long serialVersionUID = 1L;
	// 代码
	private String code;
	// 消息
	private String message;
	// 是否成功
	private boolean success;
	// 主要数据
	private Object data;
	// 时间
	private LocalDateTime time;

	public AppResponse() {
		this.time = LocalDateTime.now();
	}

	public AppResponse(boolean success, String code, String message, Object data) {
		this.code = code;
		this.message = message;
		this.success = success;
		this.data = data;
		this.time = LocalDateTime.now();
	}

	public AppResponse error(String code, String message) {
		this.code = code;
		this.message = message;
		this.success = false;
		return this;
	}

	public AppResponse success(Object data) {
		this.code = "0";
		this.message = "操作成功";
		this.success = true;
		this.data = data;
		return this;
	}

	public String getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public LocalDateTime getTime() {
		return time;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	
	
}
